﻿using System.Windows.Controls;

namespace SGGWElevator
{
    /// <summary>
    /// Interaction logic for ElevatorStatusLabel.xaml
    /// Author: Paweł Żurawik
    /// </summary>
    public partial class ElevatorStatusLabel : UserControl
    {
        /// <summary>
        /// Local variable. Should be accesed via Status accessor. 
        /// </summary>
        ElevatorStatus _status = ElevatorStatus.Waiting;

        /// <summary>
        /// Elevator status
        /// </summary>
        public ElevatorStatus Status
        {
            get { return _status; }
            set
            {
                // Check is the same
                if (_status == value)
                    return;

                // Change status
                _status = value;

                // Change labels content
                StatusLabel.Content = DictStatusLabels.GetByFirst(value);
            }
        }


        /// <summary>
        /// Bidirection dictionary containing definitions for elevator statuses and their labels. 
        /// </summary>
        BiDictionary<ElevatorStatus, string> DictStatusLabels;

        public ElevatorStatusLabel()
        {
            InitializeComponent();

            DictStatusLabels = new BiDictionary<ElevatorStatus, string>();
            DictStatusLabels.Add(ElevatorStatus.Closing, Constants.CLOSING_STATUS);
            DictStatusLabels.Add(ElevatorStatus.Moving, Constants.MOVING_STATUS);
            DictStatusLabels.Add(ElevatorStatus.Opening, Constants.OPENING_STATUS);
            DictStatusLabels.Add(ElevatorStatus.Waiting, Constants.WAITING_STATUS);
        }

        public class Constants
        {
            public const string WAITING_STATUS = "WAITING";
            public const string MOVING_STATUS = "MOVING";
            public const string OPENING_STATUS = "OPENING";
            public const string CLOSING_STATUS = "CLOSING";
        }
    }
}
